﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataSetTableAdapters;

public partial class userinfedit : System.Web.UI.Page
{
    private string oldEmail;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }
        tb_MemberTableAdapter adapter = new tb_MemberTableAdapter();
        DataSet.tb_MemberDataTable datatable = new DataSet.tb_MemberDataTable();
        datatable = adapter.GetMemberInformation(Request.QueryString["email"].ToString());
        userNameTextBox.Text = datatable[0].UserName;
        userPassword.Text = datatable[0].UserPwd;
        userEmail.Text = datatable[0].Email;
        //oldEmail = Request.QueryString["email"].ToString();
        ContentPlaceHolder holder = (ContentPlaceHolder)Master.FindControl("loginHolder");
        Label loginLabel = (Label)holder.FindControl("loginLabel");
        loginLabel.Text = Request.QueryString["email"].ToString();

        if (datatable[0].IsRealNameNull())
        {
            userRealName.Text = "";
        }
        else
        {
            userRealName.Text = datatable[0].RealName;
        }
        if (datatable[0].IsUserAddressNull())
        {
            userAddress.Text = "";
        }
        else
        {
            userAddress.Text = datatable[0].UserAddress;
        }
        if (datatable[0].IsTelNull())
        {
            userTel.Text = "";
        }
        else { userTel.Text = datatable[0].Tel; }
        if (!datatable[0].IsSexNull())
        {
            if (datatable[0].Sex == true)
            {
                sexMan.Checked = true;
                sexWomen.Checked = false;

            }
            else
            {
                sexWomen.Checked = true;
                sexMan.Checked = false;
            }
        }

    }


    protected void savebtn_Click(object sender, EventArgs e)
    {
        tb_MemberTableAdapter adapter = new tb_MemberTableAdapter();
        bool? sex = null;
        if (sexMan.Checked == false && sexWomen.Checked == false)
        {
            sex = null;
        }
        else if (sexMan.Checked)
        {

            sex = true;
        }
        else if (sexWomen.Checked)
        {
            sex = true;
        }
         adapter.UpdateQuery(userEmail.Text, userNameTextBox.Text, userRealName.Text, userPassword.Text, userAddress.Text, userTel.Text, sex, null, null, Request.QueryString["email"].ToString());
        return;
    }
}